#include<stdio.h>
#include<math.h>

long cau(int k,int n);

int main()
{
	int k,n;

	scanf("%d%d",&k,&n);
	
	printf("%ld\n",cau(k,n));
}

long cau(int k,int n)
{
	long mid;
	if(n == 1)	return 1;
	else
		return (long)(pow(n,k)) + cau(k,n-1);
}
